// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import MTX from "../../../pictures/TX/MTX/MTX";
import weatherM from "../../../pictures/map/weather/weatherM";
import YP from "../../../sound/music";
import ComponentBase from "../../BASE/ComponentBase";
import GeZi from "../../Ditu/Gezi/GeZi";
import fireball from "../../Ditu/des/fireball";
import AnimalManager from "../../Manager/AnimalManager";
import GeZiManager from "../../Manager/GeZiManager";
import GMessage from "../../Message/GMessage";
import KHD from "../../Message/KHD";
import { Message } from "../../Message/Message";
import MessageCenter from "../../Message/MessageCenter";
import { SHMessage } from "../../Message/SHMessage";
import S03 from "../../Scharacter/S03";
import TUT from "../../game/TUT";
import state from "../../game/time/state";
import turn from "../../game/time/turn";
import MAG from "./MAG";





const {ccclass, property} = cc._decorator;

@ccclass
export default class MUI extends ComponentBase {
  DZLM:boolean=false; 
    DLLM: string = "n";
    QD: boolean = false;
    @property(Number)  
    CC: number = 0;
    MCD:number[]=[0,0,0,0,0,0,5,0,0,0,7,0,0,0,0,0,0]
    DMAG:number=0;
    fashu: number[] = [4,10,3,8];
    BLfas:number[]=[7,9,14];
    RLfas:number[]=[6,2,10];
   son:MAG[]=[];
   @property(cc.Node)  
   di:cc.Node=null
   roundPass(): void {
      for (let index = 0; index < this.MCD.length; index++) {
        if (this.MCD[index]>0) {
            this.MCD[index]-=1
        }
        
      }
   
   console.log(this.MCD)
   
    }

   
    ST(){


for(let c of this.son){
c.ST()



}
   }

chushi(){
let k
let o=GeZiManager.PCP.color;

    if(o=="Blue"){k=this.mArr1Arr2(this.fashu,this.BLfas)}else{k=this.mArr1Arr2(this.fashu,this.RLfas)}
    if(GeZiManager.PCP.getComponent(S03)&&GeZiManager.PCP.getComponent(S03).BL[5]>0){ k=GeZiManager.PCP.getComponent(S03).changM();}
for (let index = 0; index < k.length; index++) {
   let a=""
   let qi=0
   let t=0
    switch (k[index]) {
        case 1:a="fireball" ;qi=2;//this.MCD[1]=1;
        break;
        case 2:a="falsh" ;qi=3;//this.MCD[2]=3;
        break;
        case 3:a="cure" ;qi=3;//this.MCD[3]=5;
        break;
        case 4:a="KB" ;qi=3;//this.MCD[10]=4;
        break;
        case 5:a="earthquake" ;qi=4;//this.MCD[4]=5;
        break;
        case 6:a="wind" ;qi=5;//this.MCD[5]=4;
        break;
        case 7:a="TP" ;qi=6;//this.MCD[6]=2;
        break;
       
      
        case 8:a="ice" ;qi=3;//this.MCD[7]=4;
        break;
        case 9:a="banana" ;qi=2;//this.MCD[8]=2;
        break;
        case 10:a="thunder" ;qi=6;//this.MCD[9]=7;
        break;
       
        case 11:a="tree" ;qi=3;//this.MCD[10]=4;
        break;
      
        case 12:a="BZ";qi=3;//this.MCD[10]=4;
        break;
        case 13:a="pig" ;qi=3;//this.MCD[10]=4;
        break;
        case 14:a="tui" ;qi=3;//this.MCD[10]=4;
        break;
    default:a="BZ";qi=3
        break;
   }
    this.son[index].js(qi,k[index],t,a)
}
console.log()
}

open(){ 
   this.node.position=cc.v3(-1420,-1000,0) 
   this.di.position=cc.v3(-738,0,0) 
// 移动节点 this.node 的 y 坐标
cc.tween(this.node).to(0.2, { y: this.node.y+520 }).start();
// 移动节点 this.di 的 x 坐标
cc.tween(this.di).to(0.3, { x: this.di.x+760 }).start();
cc.tween(this.node).to(0.2, { x: this.node.x+30}).start();
setTimeout(() => {
    cc.tween(this.di).to(0.05, { x: this.di.x-30}).start();
    cc.tween(this.node).to(0.05, { y: this.node.y-40 }).start();
    cc.tween(this.node).to(0.05, { x: this.node.x+20 }).start();
}, 310);

setTimeout(() => {
    cc.tween(this.node).to(0.05, { y: this.node.y+20 }).start();
    cc.tween(this.node).to(0.05, { x: this.node.x-10 }).start();
}, 370);
console.log("open")

this.chushi()
this.ST();
}


    close(){
        
        cc.tween(this.di).to(0.3, { x: this.di.x-730 }).start();
        cc.tween(this.node).to(0.3, { y: this.node.y-500 }).start();
        cc.tween(this.node).to(0.05, { x: this.node.x-40 }).start();
    // 移动节点 this.di 的 x 坐标
    console.log("close")
    GeZiManager.PCP.ST()
GeZiManager.JL=0
 }












XZ(n:number){
    let k=GeZiManager.redM;
    let o=GeZiManager.blueM
if(GeZiManager.PCP.color=="Blue"){o=GeZiManager.redM;k=GeZiManager.blueM}
state.ST=4;
    MessageCenter.MakeMessage("UIManager","change",-1);
    for(let manager of GeZiManager.YuanGong){
let a=new Message("",[65],-1)
        manager.ReceiveMessage(a)    
}
MessageCenter.MakeMessage("AM",turn.turn,"getZB")

for(let manager of GeZiManager.YuanGong){
manager.getFar(n+GeZiManager.JL);
if (k.includes(manager.ZB)&&!o.includes(manager.ZB)) {
    manager.red();
}
}


}






 onLoad(): void {
    turn.Roo.push(this)
}

   start () {
    MessageCenter.addReceive(this);

this.chushi();
}
   

 qic(qic:number){
   
if(GeZiManager.PCP.qi>=qic){    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],qic,null,"Qi-");

return true}else{
    
    
    
    return false}


 } 


back(){
    this.close()
    MessageCenter.MakeMessage("UIManager","change",1);
  cc.find("Canvas").getComponent(YP).ZJP("uyp",false,1)
GeZiManager.clean();
    
}


//火球术
fireball(){


this.XZ(4)
      
GeZiManager.DLLM='fireball'
this.close();



}


Dfireball(n:number){
  
 //  if(GeZiManager.PCP.FU[0]>0){GeZiManager.dm+=1}
for(let a of GeZiManager.PCP.magic2){a.Magic2();}

MessageCenter.MakeSHMessage("AM",[n,2+GeZiManager.dm],4,GeZiManager.PCP.Pturn,"FTP");
MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],2+GeZiManager.free,null,"Qi-")
for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}


cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,0)

}

/////////////////闪现
falsh(){ 
   



    
        let a  = GeZiManager.PCP.findGe(GeZiManager.PCP.faceTo,2)
        cc.find("Canvas/DituManager/New Node/AnimalManager/GUIManager").active=true;
         
        for(let c of GeZiManager.YuanGong){


            if(c.ZB==a){if(GeZiManager.BanMove.includes(c.ZB)){c.red(); MessageCenter.MakeMessage("UIManager","change",-1)}else{c.blue();  MessageCenter.MakeMessage("UIManager","change",2)}}else c.null();
            if (GeZiManager.grass.includes(c.ZB)) {
                c.puper();  MessageCenter.MakeMessage("UIManager","change",2)
            }
        }

        this.close();
        GeZiManager.DLLM='falsh'
        state.ST=4;

}
Dfalsh(){
    console.log("dg")
 for(let a of GeZiManager.PCP.magic2){a.Magic2();}
    
    let k  = GeZiManager.PCP.findGe(GeZiManager.PCP.faceTo,2)
    if(GeZiManager.BanMove.includes(k)){}else{
     
        GeZiManager.PCP.To(k,0.1);
    
}
MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],3+GeZiManager.free,null,"Qi-")

    for(let a of GeZiManager.PCP.magic3){a.Magic3(k);}




  cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,1)
              


}
KB(){
    let a  = GeZiManager.PCP.ZB
    cc.find("Canvas/DituManager/New Node/AnimalManager/GUIManager").active=true;
     
    for(let c of GeZiManager.YuanGong){


        if(c.ZB==a){c.blue();  MessageCenter.MakeMessage("UIManager","change",2)}else c.null();
      
    }



  
        GeZiManager.DLLM='KB'
        state.ST=4;
        this.close();}


DKB(){for(let a of GeZiManager.PCP.magic2){a.Magic2();}
GeZiManager.PCP.KB+=2
GeZiManager.PCP.sh+=1

MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],3+GeZiManager.free,null,"Qi-")
for(let a of GeZiManager.PCP.magic3){a.Magic3(GeZiManager.PCP.ZB);}
 
}
pig(){ 
   



    
    let a  = GeZiManager.PCP.findGe(GeZiManager.PCP.faceTo,1)
    cc.find("Canvas/DituManager/New Node/AnimalManager/GUIManager").active=true;
     
    for(let c of GeZiManager.YuanGong){


        if(c.ZB==a){if(GeZiManager.BanMove.includes(c.ZB)){c.red(); MessageCenter.MakeMessage("UIManager","change",-1)}else{c.blue();  MessageCenter.MakeMessage("UIManager","change",2)}}else c.null();
        if (GeZiManager.grass.includes(c.ZB)) {
            c.puper();  MessageCenter.MakeMessage("UIManager","change",2)
        }
    }

    this.close();
    GeZiManager.DLLM='pig'
    state.ST=4;

}
Dpig(){
console.log("dg")
for(let a of GeZiManager.PCP.magic2){a.Magic2();}

let  k = GeZiManager.PCP.findGe(GeZiManager.PCP.faceTo,1)

MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],4+GeZiManager.free,null,"Qi-")

for(let a of GeZiManager.PCP.magic3){a.Magic3(k);}
if(GeZiManager.BanMove.includes(k)){}else{
    MessageCenter.MakeGMessage("AM",[k,GeZiManager.PCP.turn8([GeZiManager.PCP.faceIs(k)])[0]],21,1,"FTP");
  

}


}

cure(){
    state.ST=4;
    MessageCenter.MakeMessage("UIManager","change",-1);
            let a=new Message("",[65],-1)
            for(let manager of GeZiManager.YuanGong){
            
                manager.ReceiveMessage(a)    
    }
    MessageCenter.MakeMessage("AM",turn.turn,"getZB")
    
    for(let manager of GeZiManager.YuanGong){
      manager.getFar(4+GeZiManager.JL);
    if(GeZiManager.BanMove.includes(manager.ZB)){
    
        
    }else{  manager.red(); }
        }

        GeZiManager.DLLM='cure'
        this.close();
}
Dcure(n:number){
    for(let a of GeZiManager.PCP.magic2){a.Magic2();}
   

   
   MessageCenter.MakeSHMessage("AM",[n],1,GeZiManager.PCP.Pturn,"getOne")
   if(GeZiManager.Tcharacter!=null){GeZiManager.Tcharacter.node.getChildByName("MTX").getComponent(MTX).playFrameAnimation1("cure")}
   setTimeout(() => {
    MessageCenter.MakeSHMessage("AM",[n],1,GeZiManager.PCP.Pturn,"HP+");
   
    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],3+GeZiManager.free,null,"Qi-")
    for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}
   }, 500); 

   cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,2)

}








////////////////地震
earthquake(){
if(this.DZLM){}else{
    state.ST=4;
    GeZiManager.DLLM='earthquake'
    MessageCenter.MakeMessage("UIManager","change",2);
    for(let c of GeZiManager.YuanGong){


        if([1,8].includes(c.X)||[1,8].includes(c.Y)){c.null()}else {c.blue();}
           }
    
    this.close();
        
        }
}

Dearthquake(){ 
        GeZiManager.DLLM='earthquake'
    for(let a of GeZiManager.PCP.magic2){a.Magic2();}
    let g=cc.find("Canvas/Main Camera").getComponent(cc.Camera)
    let l=cc.find("Canvas/DituManager/New Node/AnimalManager/QP")
      cc.find("Canvas/weatherManager").getComponent(weatherM).shakeCameraAndNode(g,l,13,3000)
      let a=cc.find("Canvas/DituManager/New Node/AnimalManager").getComponent(AnimalManager).YuanGong;
      
      setTimeout(() => {
       
        for(let manager of a) {
        
        if(manager.DiXing=="grass"){manager.ReceiveMessage(b);manager.ReceiveMessage(c);}
        
           }
      }, 1500);
 let o=[GeZiManager.PCP.teammates[0].ZB,GeZiManager.PCP.teammates[1].ZB]
      let c=new SHMessage("AM",[o],GeZiManager.dm,turn.turn,"Dun")
      let b=new SHMessage("AM",[65],[1+GeZiManager.dm,"DZ"],turn.turn,"mofaT")
    
      cc.find("Canvas/UIManager/magicUI").getComponent(MUI).DZLM=false    
MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],4+GeZiManager.free,null,"Qi-")

   for(let a of GeZiManager.PCP.magic3){a.Magic3(GeZiManager.PCP.ZB);}
   cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,3)
}


////////////////////////



ice(){
  
        GeZiManager.DLLM='ice'
        state.ST=4;
      
        MessageCenter.MakeMessage("UIManager","change",-1);
                let a=new Message("",[65],-1)
                for(let manager of GeZiManager.YuanGong){
                
                    manager.ReceiveMessage(a)    
        }
        MessageCenter.MakeMessage("AM",turn.turn,"getZB")
        
        for(let manager of GeZiManager.YuanGong){
          manager.getFar(4+GeZiManager.JL);
        if(GeZiManager.BanMove.includes(manager.ZB)&&(GeZiManager.trees.includes(manager.ZB)==false)){
        
            
        }else{  manager.red(); }

if (GeZiManager.waterPool.includes(manager.ZB)) {
    manager.green();
}

            } 
       this.close();
}

Dice(n:number){
       GeZiManager.DLLM='ice'
    for(let a of GeZiManager.PCP.magic2){a.Magic2();}
 
    MessageCenter.MakeSHMessage("AM",[n],1,GeZiManager.PCP.Pturn,"ice");
    MessageCenter.MakeSHMessage("AM",[n],GeZiManager.dm,GeZiManager.PCP.Pturn,"Qi-");
    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],3+GeZiManager.free,null,"Qi-")
    for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}


    cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,5)
}



wind(){

 

        GeZiManager.DLLM='wind'
        state.ST=4;  
 MessageCenter.MakeMessage("UIManager","change",5);
 this.close();


}

Dwind(n:number){
    console.log(n);
   GeZiManager.DLLM='wind'
    cc.find("Canvas/weatherManager").getComponent(weatherM).Wwind(n)
   
setTimeout(() => {
    
    cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,4)


    for(let a of GeZiManager.PCP.magic2){a.Magic2();}
  //  if(GeZiManager.PCP.FU[3]>0){GeZiManager.free-=1}
    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],5+GeZiManager.free,null,"Qi-")
 for (let index = 0; index < 1+GeZiManager.dm; index++) {
   
    
   for(let m of GeZiManager.WindSon){m.WDT();}  
   switch (n) {
       
       case 2:for(let i=1;i<=8;i++){
           GeZiManager.getWD(2);
           MessageCenter.MakeSHMessage("AM",GeZiManager.onY(i),2,GeZiManager.PCP.Pturn,"wind");
   console.log(GeZiManager.rock+","+GeZiManager.WD)
   
   
       }
           
           break;
         
   case 4:for(let i=1;i<=8;i++){
   GeZiManager.getWD(4);
                   MessageCenter.MakeSHMessage("AM",GeZiManager.onX(i),4,GeZiManager.PCP.Pturn,"wind");
           
          
      
               }
                   
                   break;
   case 6:for(let i=8;i>=1;i--){
       GeZiManager.getWD(6);
                       MessageCenter.MakeSHMessage("AM",GeZiManager.onX(i),6,GeZiManager.PCP.Pturn,"wind");
               
               
    
                   }
                       
                       break;
    case 8:for(let i=8;i>=1;i--){
       GeZiManager.getWD(8);
                           MessageCenter.MakeSHMessage("AM",GeZiManager.onY(i),8,GeZiManager.PCP.Pturn,"wind");
                   
                       }
                           
                           break;
       default:
           break;
   }
   
   

   
   
   GeZiManager.Ban=[];

  for (let a of GeZiManager.GR) {
  a.wind()
    
  }
   
} 
   
   for(let a of GeZiManager.PCP.magic3){a.Magic3(GeZiManager.PCP.ZB);}
}, 600);
   }




W2(){GeZiManager.GeZi=2;MessageCenter.MakeMessage("UIManager","change",2.5);}
W4(){GeZiManager.GeZi=4;MessageCenter.MakeMessage("UIManager","change",2.5);}
W6(){GeZiManager.GeZi=6;MessageCenter.MakeMessage("UIManager","change",2.5);}
W8(){GeZiManager.GeZi=8;MessageCenter.MakeMessage("UIManager","change",2.5);}





thunder(){
   
    GeZiManager.DLLM='thunder'

    state.ST=4;
    this.close();
    MessageCenter.MakeMessage("UIManager","change",-1);  
    let a=new Message("",[65],-1)
    for(let manager of GeZiManager.YuanGong){
    
        manager.ReceiveMessage(a)    
}
MessageCenter.MakeMessage("AM",turn.turn,"getZB")

for(let manager of GeZiManager.YuanGong){
manager.getFar(4+GeZiManager.JL);}

    
}

Dthunder(n:number){
   GeZiManager.JL=0;
    for(let a of GeZiManager.PCP.magic2){a.Magic2();}
MessageCenter.MakeSHMessage("AM",[n],1,0,"getOneC")

this.fadeINAndA(cc.find("Canvas/weatherManager/th"),300);
setTimeout(() => {if (GeZiManager.Tcharacter) {
    GeZiManager.Tcharacter.node.getChildByName("MTX").getComponent(MTX).playFrameAnimation1("thunder");
}

    this.fadeOutAndDisappear(cc.find("Canvas/weatherManager/th"),300);
}, 300);

    MessageCenter.MakeSHMessage("AM",[n],2,GeZiManager.PCP.Pturn,"mofa");

    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],6+GeZiManager.free,null,"Qi-")
    for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}

    cc.find("Canvas").getComponent(YP).PlayAudioclip("myp",false,6)
}



TP(){ 
 
    state.ST=4;
    GeZiManager.DLLM='TP'
    this.XZ(4)   
    this.close(); 
  }



    DTP(n:number){
        for(let a of GeZiManager.PCP.magic2){a.Magic2();}
        
     
        GeZiManager.PCP.To(n,0);
        MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],6+GeZiManager.free,null,"Qi-")
        for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}
    }

    banana(){
   
            state.ST=4;
             
            GeZiManager.DLLM='banana'
            this.XZ(4);  
            this.close();
        
    }
    
    Dbanana(n:number){
        for(let a of GeZiManager.PCP.magic2){a.Magic2();}
  
       
        MessageCenter.MakeSHMessage("AM",[n],7,GeZiManager.PCP.Pturn,"FTP");
    
        for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}
    }



BZ(){


    let a  = GeZiManager.PCP.getNIGno5( GeZiManager.PCP.ZB)
    cc.find("Canvas/DituManager/New Node/AnimalManager/GUIManager").active=true;
     
    for(let c of GeZiManager.YuanGong){


        if(a.includes(c.ZB)){ MessageCenter.MakeMessage("UIManager","change",-1);c.blue();  MessageCenter.MakeMessage("UIManager","change",2)}else c.null();
      
    }

    this.close();
    GeZiManager.DLLM='BZ'
    state.ST=4;

}

DBZ(){



    for(let a of GeZiManager.PCP.magic2){a.Magic2();}
    
    let a  = GeZiManager.PCP.getNIGno5( GeZiManager.PCP.ZB)
    MessageCenter.MakeSHMessage("AM",a,1,GeZiManager.PCP.Pturn,"mofa")
MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],3+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-")

    for(let a of GeZiManager.PCP.magic3){a.Magic3(GeZiManager.PCP.ZB);}



}



tree(){
   
    state.ST=4;
     
    GeZiManager.DLLM='tree'
    this.XZ(4);  
    this.close();

}

Dtree(n:number){
for(let a of GeZiManager.PCP.magic2){a.Magic2();}


MessageCenter.MakeSHMessage("AM",[n],1,GeZiManager.PCP.Pturn,"FTP");
MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],2+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-")
for(let a of GeZiManager.PCP.magic3){a.Magic3(GeZiManager.PCP.ZB);}
}

tui(){


    let a  = GeZiManager.PCP.findGe(GeZiManager.PCP.faceTo,1)
    cc.find("Canvas/DituManager/New Node/AnimalManager/GUIManager").active=true;
     
    for(let c of GeZiManager.YuanGong){


        if(c.ZB==a){c.blue();  MessageCenter.MakeMessage("UIManager","change",2)}else c.null();
      
    }

    this.close();
    GeZiManager.DLLM='tui'
    state.ST=4;





}



Dtui(n:number){
    n = GeZiManager.PCP.findGe(GeZiManager.PCP.faceTo,1)
    for(let a of GeZiManager.PCP.magic2){a.Magic2();}

    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],3+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-")
    MessageCenter.MakeSHMessage("AM",[n],[GeZiManager.PCP.turn8([GeZiManager.PCP.faceIs(n)])[0],0.3],GeZiManager.PCP.Pturn,"move")
    console.log(GeZiManager.PCP.faceIs(n))
    for(let a of GeZiManager.PCP.magic3){a.Magic3(n);}


}






ReceiveMessage(message: Message): void {
    if(message instanceof SHMessage&& message.Type=="MUI"){
console.log(message)
MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.TNJJ[5]+GeZiManager.TNC[4],GeZiManager.PCP.Pturn,"TN-");
switch (message.SHtype) {
    case 'fireball':this.Dfireball(message.Content);//if(this.PPC()){this.MCD[1]+=2}
        
        break;
        case 'falsh':this.Dfalsh();//if(this.PPC()){this.MCD[2]+=3}
        
        break;
        case 'cure':this.Dcure(message.Content);//if(this.PPC()){this.MCD[3]+=3}
        
        break;
        case 'wind':this.Dwind(message.Content);//if(this.PPC()){this.MCD[4]+=4};
        
        break;
        case 'ice':this.Dice(message.Content);//if(this.PPC()){this.MCD[5]+=4}
        
        break;
        case 'earthquake':this.Dearthquake();//if(this.PPC()){this.MCD[6]+=5}
        
        break;
        case 'TP':this.DTP(message.Content);//if(this.PPC()){this.MCD[7]+=5}
        
        break;
        case 'thunder':this.Dthunder(message.Content);//if(this.PPC()){this.MCD[8]+=5}
        
        break;
        case 'banana':this.Dbanana(message.Content);//if(this.PPC()){this.MCD[9]+=3}
        
        break;
        case 'KB':this.DKB();//if(this.PPC()){this.MCD[1]+=4}
        
        break;
        case 'BZ':this.DBZ();//if(this.PPC()){this.MCD[1]+=4}
        
        break;
        case 'tree':this.Dtree(message.Content);//if(this.PPC()){this.MCD[1]+=4}
        
        break;
        case 'pig':this.Dpig();//if(this.PPC()){this.MCD[1]+=4}
        
        break;
        case 'tui':this.Dtui(message.Content);//if(this.PPC()){this.MCD[1]+=4}
        
        break;
    default:
        break;
}





GeZiManager.clean();   

    }
}





moveRight(node: cc.Node, duration: number, distance: number) {
    const startPos = node.position;
    const endPos = cc.v2(startPos.x + distance, startPos.y);
    node.runAction(cc.moveTo(duration, endPos));
  }

DK(){this.moveRight(this.node,0.5,500);}
GB(){this.moveRight(this.node,0.5,-500)}












getc(nu:number){


    switch (nu) {
      case -1:
      
       case 1:return GeZiManager.P1
          
          break;
          case 2:return GeZiManager.P2
          
          break;
          case 3:return GeZiManager.P3
          
          break;
          case 4:return GeZiManager.P4
          
          break;
          case 5:return GeZiManager.P5
          
          break;
          case 6:return GeZiManager.P6
          
          break;
    
       default:
          break;
    }
    } 
}
/*
 1  火球(fireball)【2】{2}：施法者指定以自身为中心的4格范围内的任意一格引导火球，在下一次轮到施法者的回合时，该指定格火球降下，对该格单位造成2点魔法伤害，若命中地雷会直接将其引爆

 5  闪现(flash)【3】{3}：施法者立即位移至面朝方向的的第二格上，可以越过任意单位（若面朝方向第二格上已有单位则无法使用）

 6  治疗术(crue)【3】{3}：施法者指定以自身为中心的3格范围内的一个非敌方且可回复生命值的单位，使其回复1点生命值

 3  地震(earthquake)【4】{5}：施法者进行蓄力，在下一次轮到施法者的回合时立即使地面上的所有实体单位受到1点伤害（水中不受影响）

 4  飓风(wind)【5】{4}：施法者指定一个方向，使场上所有单位向指定方向进行正常力度的位移判定

 8  传送(TP)【7】{5}：施法者指定场上没有实体单位的任意一格，立即位移至该格（朝向不变）

 2  冰冻(frozen)【3】{4}：施法者指定以自身为中心的3格范围内的任意一格（不包括自己），使该格单位无法移动和转身且获得1点假血（抵消1点伤害），持续到下一次轮到施法者的回合为止

 7  香蕉皮(banana)【2】{3}：施法者指定以自身为中心的3格范围内没有单位的一格，使该格地面变滑，任意单位在经过变滑地面时会继续位移至下一格（除非有其他单位阻挡在下一格）

 9  雷电(thunder)【6】{5}：施法者指定场上的任意单位，立即对其造成2点魔法伤害

 10  狂暴(crazy)【4】{4}：（该法术的释放不消耗体能）施法者立即获得2点体能，直到下回合结束

 */